package com.ceiling.controller;

import com.ceiling.bean.BaseRespVo;
import com.ceiling.bean.goods.bo.InfoBo;
import com.ceiling.bean.goods.bo.LoginUserBo;
import com.ceiling.bean.goods.vo.CatAndBrandVo;
import com.ceiling.bean.goods.vo.GoodsDataVo;
import com.ceiling.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class GoodsController {

    @Autowired
    GoodsService goodsService;


    @RequestMapping("admin/auth/login")
    public BaseRespVo login(@RequestBody LoginUserBo user) {

        return BaseRespVo.ok("ceiling","成功");
    }

    @RequestMapping("admin/auth/info")
    public BaseRespVo info(String token) {
        InfoBo info = new InfoBo();
        ArrayList<String> roles = new ArrayList<>();
        roles.add("超级管理员");
        info.setRoles(roles);
        info.setName("admin123");
        ArrayList<String> perms = new ArrayList<>();
        perms.add("*");
        info.setPerms(perms);
        info.setAvatar("ceiling");

        return BaseRespVo.ok(info, "成功");
    }

    @RequestMapping("admin/dashboard")
    public BaseRespVo dashboard() {


        return BaseRespVo.ok();
    }


    @RequestMapping("admin/goods/list")
    public BaseRespVo list(Integer page, Integer limit, String sort, String order,String goodsSn,String name) {
        GoodsDataVo goodsDataVo = goodsService.selectGoodsData(page, limit, sort, order,goodsSn,name);
        return BaseRespVo.ok(goodsDataVo,"成功");
    }


    @RequestMapping("admin/goods/catAndBrand")
    public BaseRespVo catAndBrand() {

        CatAndBrandVo catAndBrandVo = goodsService.catAndBrand();

        return BaseRespVo.ok(catAndBrandVo,"成功");
    }
}
